package config

import (
	"log/slog"
	"os"
	"path/filepath"
	"sailing.cn/v2/conf"
)

type Config struct {
	conf.WebapiConfig `mapstructure:",squash"`
}

var CFG = &Config{}

var Folder string

func Init() {
	var cfg = Folder
	if Folder == "" {
		Folder, _ = os.Executable()
		Folder = filepath.Dir(Folder)
		cfg = filepath.Join(Folder, "conf.d")
	}
	slog.Info("配置文件", "目录", cfg)
	CFG, _ = conf.NewConf[Config](cfg)
}
